home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia 1995 April / Informatica Multimedia CD - Epimundo.iso / DOS / FMT_COPY / FDREAD.ZIP / TECHIE.POO < prev    next >
Encoding:
Text File  |  1990-06-30  |  6.8 KB  |  129 lines

  1.                     TECHNICAL NOTES ON FDREAD v1.20cj
  2.  
  3. Some of this will be old hat to the hackers out there, but I'm going to
  4. cover some background for the rest of you.
  5.  
  6. Current versions (starting with 3.0, I think) of PC/MS-DOS use the infor-
  7. mation on the format of a diskette found in the boot sector.  DOS can look
  8. here and learn about the number of cylinders, the number of heads, and the
  9. number of sectors per track.  It also learns about the number of FATs (File
  10. Allocation Tables) and the size of the root directory.
  11.  
  12. FDFORMAT allows you to modify all of these characteristics, and it writes a
  13. boot record on the floppy disk that reflects them.
  14.  
  15. Most versions of DOS will use this information to control their file system
  16. on floppies.  There may be some DOSs out there that don't: ancient ones, or
  17. poorly modified versions, or ineptly written clones.  If you have such a
  18. DOS you can't use over-formatted disks.
  19.  
  20. DISKCOPY and DISKCOMP pay no attention the the data on a disk, but they
  21. only know about the standard DOS formats and will not copy or compare
  22. diskettes with unusual numbers or sectors per track or unusual numbers of
  23. cylinders.
  24.  
  25. If you decide to go for stranger formats, to back them up you must FDFORMAT
  26. another disk and use file copy functions to copy the files.
  27.  
  28. But this is not DOS' problem; it's the problem of DISKCOPY and DISKCOMP.
  29.  
  30. Even if you insist on using DISKCOPY or similar programs (PCSHELL's Disk
  31. Copy funtion, for instance) you can still get value from FDFORMAT.  You
  32. can, for example, format a 360K diskette with 9 sectors per track and forty
  33. cylinders and two heads (the normal for a 360K disk) but with 176 entries
  34. in the root directory and 1 sector per allocation cluster (two is normal
  35. here).  Such a diskette will have about 2K less space for data than a
  36. normal 360K diskette, but it a better format for a diskette on which you
  37. are storing lots of small files (letters, for example) since you will run
  38. out of root directory and diskette space at about the same time and there
  39. will be MUCH less space wasted in the partially used last cluster of each
  40. file.
  41.  
  42. Most important: such a disk can be easily copied and compared with DISKCOPY
  43. and DISKCOMP.  You won't need to use FDREAD, either.
  44.  
  45. Most other programs with similar functions will not do well with over-
  46. formatted disks.  Some will do the job correctly.  COPYIIPC, for example
  47. will copy over-formatted "DD" disks, though it may have some problems going
  48. over 80 tracks (I haven't tried), and it may not handle high-density
  49. diskettes.
  50.  
  51. You may have some other software that has problems, but as long as they use
  52. the DOS file system, you'll probably be all right.
  53.  
  54. The REAL problems we have are with the BIOS.
  55.  
  56. From the beginning the BIOSs have gotten their information about the
  57. parameters used to set up the Floppy Disk Controller from a Diskette
  58. Parameter Table whose address is stored in interrupt vector 1Eh (the four
  59. bytes beginning at location 0000:0078h).  This table contains such things
  60. as the diskette seek step time, the size of the inter-sector gaps for
  61. formatting, and other things.  But to us the important item is the number of
  62. sectors per track. The BIOS uses this value to determine the maximum sector
  63. number which it must give to the FDC (Floppy Disk Controller) as part of
  64. the command sequence for things like reading, writing and verifying.  The
  65. FDC will stop transferring data from a track after it encounters a sector
  66. with this number.  It is also used to tell the FDC how many sectors there
  67. are per track when it is formatting. If you have a diskette with 9 sectors
  68. per track, but you set the FDC to look for a maximum of 8, and you ask it
  69. to read 9 sectors, it will read the first 8 sectors, then return a sector
  70. not found error on the sector 9, even though sector 9 is out there.
  71.  
  72. The original version of FDREAD intercepts the calls to the BIOS for disk
  73. services.  If it sees a READ, WRITE or VERIFY command, it just plugs a
  74. sufficiently large value (25) into the Floppy Disk Parameter Table to
  75. ensure the reading of the track.
  76.  
  77. Now let's see what happens when we try to run a typical "normal" format
  78. program.  The format program sets the gap length and number of sectors per
  79. track into the Diskette Parameter Table, then calls the BIOS to format a track.
  80. So far so good.  This is not a READ, WRITE or VERIFY command, so FDREAD
  81. leaves the Diskette Parameter Table alone.  Now the format program issues a
  82. VERIFY to verify the formatted track.  Oops-- FDREAD intercepts and changes
  83. the number of sectors in the Diskette Parameter Table to 25.  The verify
  84. proceeds and is good.  Now the formatter issues a command to format the
  85. next track.  But the BIOS thinks it now has 25 sectors to write and
  86. overwrites the front part of the track with other stuff.  Now the track
  87. won't verify, since the first sector, having been overwritten, cannot be
  88. found.
  89.  
  90. Sigh.
  91.  
  92. So I have  modified FDREAD so that instead of plugging 25 into the number-
  93. of-sectors slot in the Diskette Parameter Table it checks the caller's
  94. parameters.  It adds the starting sector number (from the CL register) to
  95. the number of sectors to read (from the AL register), then knocks off 1.
  96. This will give us the sector number of the highest sector the caller wants
  97. to read.  If this exceeds the value in the Diskette Parameter Table, FDREAD
  98. replaces it.  Otherwise it leaves it alone.  Yes, the procedure is a bit
  99. more complicated, but it gets along better with more software and more
  100. BIOSs.
  101.  
  102. There will, of course, be BIOSs that don't use the Diskette Parameter Table
  103. and you won't be able to use over-formatted disks on machines so equipped.
  104. (Version 9.09 of the BIOS on the Jameco JE1049 FDC for the XT has this
  105. problem while version 7.10 [marked internally as 10.25, the version from
  106. early 1989], works fine.)  IBM ATs (real ones) work properly and several AT
  107. clones I have tried (including a Jameco model with an AMI BIOS) work just
  108. as slick as anything, but there are exceptions, so check carefully.  And if
  109. it doesn't work----
  110.  
  111. Well, hey!  You can always get your money back, right?
  112.  
  113. Of course there will be the occasional piece of software that can't live
  114. with our modified FDREAD.  For those programs I have added the OFF and ON
  115. feature.  For those of you who are writing software for which you MUST have
  116. FDREAD's functions OFF, you can even make a call (thru interrupt 13h) to
  117. turn FDREAD on and off.  Check the listing of the modified FDREAD for
  118. instructions and examples.
  119.  
  120. There is some additional code in FDREAD which can be activated by assem-
  121. bling it with the symbol MODE defined as 2, but this will only work on AT
  122. systems, and is for dealing with quad density 720K 5-1/4" floppies.  The
  123. assembled and lunk (sink/sunk, drink/drunk, and all that) version in this
  124. package was assembled with MODE not defined so the extra code is NOT incor-
  125. porated.
  126.  
  127.  
  128. June, 1990 -- Crazy Jack
  129.